home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / plnk081.zip / pilot-link.0.8.1 / include / pi-appinfo.hxx < prev    next >
Text File  |  1997-08-01  |  3KB  |  77 lines

  1. #ifndef __PI_APP_INFO_HXX        /* -*- C++ -*- */
  2. #define __PI_APP_INFO_HXX
  3.  
  4. #ifdef __cplusplus
  5.  
  6. #include "pi-macros.h"
  7.  
  8. const BASE_APP_INFO_SIZE = 278;    // All apps take up 278 bytes of the same stuff
  9.  
  10. typedef char category_t[16][16];
  11. typedef const char *const charConst_t;
  12. typedef const unsigned char *const ucharConst_t;
  13.  
  14. class appInfo_t 
  15. {
  16.    protected:            // Use protected since we will be subclassed
  17.      int _renamedCategories;
  18.      category_t _categoryName;
  19.      unsigned char _categoryID[16];
  20.      unsigned char _lastUniqueID;
  21.  
  22.      void baseAppInfoPack(unsigned char *);
  23.      
  24.    public:
  25.      appInfo_t(const void *);
  26.      
  27.      char *category(const int);
  28.      int categoryIndex(charConst_t) const;
  29.      int addCategory(charConst_t);
  30.      const category_t &allCategories(void) const { return _categoryName; }
  31.      int removeCategory(charConst_t);
  32.      ucharConst_t categoryID(void) const { return _categoryID; }
  33.      unsigned char lastUniqueID(void) const { return _lastUniqueID; }
  34.      int renamedCategories(void) const { return _renamedCategories; }
  35.  
  36.      virtual void *pack(void) = 0;
  37. };
  38.  
  39. class baseApp_t
  40. {
  41.    protected:            // Use protected since we will be subclassed
  42.      int _attrs;        // Attributes on this record
  43.      recordid_t _id;        // The unique ID this record was assigned
  44.  
  45.      /*
  46.       * This field stores the category this record belongs to.  It will be
  47.       * whatever the pilot said it was.  Note that if you change the categories
  48.       * for the app by calling addCategory or removeCategory in the appInfo_t
  49.       * class, these fields will become invalid.  We have no way to mark them
  50.       * invalid automatically though.  If you're going to change category names
  51.       * in your program, you can't use this field safely.
  52.       */
  53.      int _category;        // The category ID this record belongs to
  54.      
  55.      virtual void *internalPack(unsigned char *) = 0;
  56.      
  57.    public:
  58.      baseApp_t(void) : _attrs(-1), _id(0), _category(-1) {}
  59.      baseApp_t(int a, recordid_t i, int c) : _attrs(a), _id(i), _category(c) {}
  60.  
  61.      // The destructor does nothing, but we need to provide it since we have
  62.      // virtual functions
  63.      virtual ~baseApp_t(void) {}
  64.      
  65.      virtual void unpack(void *, int = 0) = 0;
  66.      virtual void *pack(int *) = 0;
  67.      virtual void *pack(void *, int *) = 0;
  68.  
  69.      int attrs(void) const { return _attrs; }
  70.      int category(void) const { return _category; }
  71.      recordid_t id(void) const { return _id; }
  72. };
  73.      
  74. #endif /*__cplusplus*/
  75.  
  76. #endif /* __PI_APP_INFO_HXX */
  77.